using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using CasaBella.Entities;

namespace CasaBella.Repository.Mapping
{
    public class CLIENTE_JURIDICOMap : EntityTypeConfiguration<CLIENTE_JURIDICO>
    {
        public CLIENTE_JURIDICOMap()
        {
            // Primary Key
            this.HasKey(t => t.ClienteJuridicoId);

            // Properties
            this.Property(t => t.ClienteJuridicoId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.Ruc)
                .IsRequired()
                .HasMaxLength(11);

            this.Property(t => t.RazonSocial)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("CLIENTE_JURIDICO");
            this.Property(t => t.ClienteJuridicoId).HasColumnName("ClienteJuridicoId");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Ruc).HasColumnName("Ruc");
            this.Property(t => t.RazonSocial).HasColumnName("RazonSocial");

            this.HasRequired(t => t.CLIENTE)
                .WithOptional(t => t.CLIENTE_JURIDICO)
                .WillCascadeOnDelete(false);
        }
    }
}
